﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WTwitter.Model.Framework;
using System.Runtime.Serialization.Json;

namespace WTwitter.Model.SearchTwitter {
	/// <summary>
	/// Search APIからの入力をアイテムに変換するクラス
	/// </summary>
	class SearchTwitterItemsReader : IItemsReader {
		#region IItemsReader メンバ

		public IEnumerable<ITimelineItem> Read(System.IO.Stream source) {
			var serializer = new DataContractJsonSerializer(typeof(SearchResult));
			var result = serializer.ReadObject(source) as SearchResult;
			foreach (var item in result.Results) {
				yield return new SearchTwitterItem(item);
			}
		}

		#endregion
	}
}
